<?php

/**
 * This is the model class for table "member".
 *
 * The followings are the available columns in table 'member':
 * @property integer $id
 * @property string $username
 * @property string $password
 * @property string $firstname
 * @property string $lastname
 * @property string $address
 * @property string $mobilephone
 * @property string $email
 * @property string $avatar
 * @property string $company
 * @property string $description
 * @property string $role
 * @property string $joindate
 * @property double $point
 * @property string $valid
 */
class Member extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Member the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'member';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('point', 'numerical'),
			array('username, firstname, lastname, email', 'length', 'max'=>30),
			array('password', 'length', 'max'=>255),
			array('address, avatar, company', 'length', 'max'=>100),
			array('mobilephone', 'length', 'max'=>12),
			array('role', 'length', 'max'=>5),
			array('valid', 'length', 'max'=>10),
			array('description, joindate', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, username, password, firstname, lastname, address, mobilephone, email, avatar, company, description, role, joindate, point, valid', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'username' => 'Username',
			'password' => 'Password',
			'firstname' => 'Firstname',
			'lastname' => 'Lastname',
			'address' => 'Address',
			'mobilephone' => 'Mobilephone',
			'email' => 'Email',
			'avatar' => 'Avatar',
			'company' => 'Company',
			'description' => 'Description',
			'role' => 'Role',
			'joindate' => 'Joindate',
			'point' => 'Point',
			'valid' => 'Valid',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('firstname',$this->firstname,true);
		$criteria->compare('lastname',$this->lastname,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('mobilephone',$this->mobilephone,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('avatar',$this->avatar,true);
		$criteria->compare('company',$this->company,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('role',$this->role,true);
		$criteria->compare('joindate',$this->joindate,true);
		$criteria->compare('point',$this->point);
		$criteria->compare('valid',$this->valid,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}